<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <title>admin</title>

    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="stylesheet" type="text/css" href="/static/css/admin/bootstrap.min14ed.css" />
	<link rel="stylesheet" type="text/css" href="/static/css/admin/font-awesome.min93e3.css" />
	<link rel="stylesheet" type="text/css" href="/static/css/admin/plugins/dataTables/dataTables.bootstrap.css">
	<link rel="stylesheet" type="text/css" href="/static/css/admin/animate.min.css" />
	<link rel="stylesheet" type="text/css" href="/static/css/admin/style.min862f.css"/>
    <link href="/static/css/admin/admincommon.css?v=20180820" rel='stylesheet' type='text/css' /> 
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>海报列表</h5>
                        <if condition="check_auth('admin/Poster/add')">
                            <button id="toggle_modal" class="btn btn-primary btn-circle" type="button" style="margin-bottom:0px;margin-left:10px;position:relative;top:-5px;" title="添加海报">
                                <i class="fa fa-edit"></i>+
                            </button>
                        </if>
                        <div class="ibox-tools">
                            <a href="javascript:location.replace(location.href);" class="btn btn-primary btn-circle" type="button" style="margin-bottom:0px;margin-right:10px;position:relative;top:-5px;" title="刷新">
                                <i class="fa fa-refresh"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <!--<form action="" method="post">
                            <div class="form-group col-sm-3" style="padding-left:0px;">
                                <input type="text" id="keywords" name="keywords" value="{$keywords}" placeholder="输入文章标题" class="form-control" onkeyup="searchTitle(this);" />
                            </div>
                            <button type="submit" class="btn btn-xm btn-primary">搜索</button>
                        </form>-->
                        <table id="mytable" class="table table-striped table-bordered table-hover dataTables-example">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>图片</th>
                                    <th>排序（小靠前）</th>
                                    <th>状态</th>
                                    <th>添加时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <volist name="data" id="vo">
                                    <tr class="gradeX" id="article-{$vo['id']}">
                                        <td>{$vo['id']}</td>
                                        <td>
                                            <img style="width:120px;height: 200px" src="{$domain}{$vo['img']}" alt="">
                                        </td>
                                        <td>{$vo['sort']}</td>
                                        <td>
                                            <if condition="$vo['status'] eq 0">
                                                正常
                                                <else/>
                                                禁用
                                            </if>
                                        </td>
                                        <td>{$vo['add_time'] | date = 'Y-m-d H:i:s',###}</td>
                                        <td class="center" align="center">
                                            <div class="btn-group">
                                                <button data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle" aria-expanded="false">操作 <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu">
                                                    <if condition="check_auth('admin/Poster/update')">
                                                        <li><a href="javascript:;" data-id="{$vo['id']}" class="font-bold edit-article">修改</a>
                                                        </li>
                                                    </if>
                                                    <if condition="check_auth('admin/Poster/del')">
                                                        <li data-id="{$vo['id']}" class="font-bold del-article"><a href="javascript:;">删除</a></li>
                                                        </li>
                                                    </if>
                                                </ul>
                                            </div>
                                        </td>
                                    </tr>
                                </volist>
                            </tbody>
                        </table>
                        {$page|raw}
                    </div>
                </div>
            </div>
        </div>
    </div>
    <js href="/static/js/admin/jquery.min.js"/>
	<js href="/static/js/admin/bootstrap.min.js"/>
	<js href="/static/js/admin/content.min.js"/>
    <js href="/static/js/admin/plugins/layui/layer/layer.js"/>
    <script type="text/javascript" src="/static/js/admin/admincommon.js?v=20180820"></script>

    <script>
    $(document).ready(function(){

        $(".ibox-content").on('click','.del-article',function(){
            var article_id = $(this).data("id");
            layer.confirm("你确定要删除ID为【"+article_id+"】的海报吗？", {

                btn: ['确定','取消'] //按钮

            }, function(){

                $.post("{:url('admin/Poster/del')}",{id:article_id},function(data){

                    if(data.code==1) {

                        layer.msg(data.msg, {time:500, icon:1});

                        $("#article-"+article_id).remove();

                    }else{

                        layer.msg(data.msg, {time:500, icon:2});

                    }

                },'json');

            });
        });

        $(".ibox-content").on('click','.edit-article',function(){
            var id = $(this).data("id");
            $(location).attr('href',"{:url('admin/Poster/update')}?id="+id);
/*            var addIndex = layer.open({
              title:'海报',
              offset: ['120px', '220px'],
              isOutAnim: true ,
              type: 2,
              content:"{:url('admin/Poster/update')}?id="+id,
              area: ['800px','400px'],
              maxmin: true
            });

            layer.full(addIndex);*/
        })

        $("#toggle_modal").on('click',function(){
            $(location).attr('href',"{:url('admin/Poster/add')}");
/*            var addIndex = layer.open({
              title:'添加海报',
              offset: ['120px', '220px'],
              isOutAnim: true ,
              type: 2,
              content:"{:url('admin/Poster/add')}",
              area: ['800px','400px'],
              maxmin: true
            });

            layer.full(addIndex);*/

        });
    });
    
    function searchTitle(obj) {
        var keywords = $.trim($(obj).val());
          
        if(keywords.length<=0) {
            window.location.replace(location.href);
        }
    } 

    </script>

</body>
</html>